package com.fh.utils.capture;

import com.fh.bean.pulc.ResultBody;
import com.fh.utils.anomaly.SpringSecurityException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@ControllerAdvice
@Slf4j
public class CustomExceptionHandler {

   /* @ExceptionHandler(AccessDeniedException.class)
    @ResponseBody
    public ResultBody<String> handleAccessDeniedException(AccessDeniedException ex) {
        log.info("是这里啊");
        return ResultBody.error(HttpServletResponse.SC_FORBIDDEN,ex.getMessage());
    }*/

    @ExceptionHandler(SpringSecurityException.class)
    @ResponseBody
    public ResultBody<String> handleAccessDeniedException(SpringSecurityException ex) {
        return ResultBody.error(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,ex.getMessage());
    }
}
